﻿Chenxin.UI.CommisionAdjust = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: '/service/logic/CommisionAdjust.ashx',
    createSearch: function() {
        return new Chenxin.UI.CommisionAdjustSearch({
            scope: this
        });
    },
    createGrid: function() {
        return new Chenxin.UI.JsonGrid({
            actionUrl: this.actionUrl + '?op=getlist',
            id: 'search_table',
            renderTo: 'search_table',
            hasCheckBox: false,
            modelId: 'departid',
            title: '佣收调整表',
            autoLoad: false,
            cellBorder: true,
            scope: this,
            height: 400,
            columns: {
                ContractCode: {
                    width: 130,
                    head: "成交编号",
                    sortable: true,
                    sortfield: 'b.ContractCode'
                },
                ContractDate: {
                    width: 90,
                    head: "成交日期",
                    sortable: true,
                    sortfield: 'ContractDate'
                },
                ArchivementDate: {
                    width: 90,
                    head: "业绩归属",
                    sortable: true,
                    sortfield: 'a.ArchivementDate'
                },
                HouseAddress: {
                    width: 230,
                    head: "房屋地址",
                    sortable: true
                },                
                AdjustType: {
                    width: 100,
                    head: "调整类型",
                    sortable: true
                },
                DiscountType: {
                    width: 100,
                    head: "折佣类型",
                    sortable: true
                },
                AdjustReason: {
                    width: 122,
                    head: "调整事由",
                    sortable: true
                },
                AdjustMoney: {
                    width: 80,
                    head: "调整金额",
                    sortable: true
                },
                BeforeAdjust: {
                    width: 80,
                    head: "调整前金额",
                    sortable: true
                },
                AfterAdjust: {
                    width: 80,
                    head: "调整后金额",
                    sortable: true
                },
                AdjustDescription: {
                    width: 400,
                    head: "调整说明",
                    sortable: true
                },
                AddDepart: {
                    width: 130,
                    head: "调整部门",
                    sortable: true,
                    sortfield: 'b.AddDepartId'
                },
                AddEmployee: {
                    width: 80,
                    head: "调整人员",
                    sortable: true,
                    sortfield: 'b.AddEmployeeId'
                },
                Addtime: {
                    width: 80,
                    head: "调整时间",
                    sortable: true,
                    sortfield: 'b.Addtime'
                }
            }
        });
    },
    initEvent: function() {
        var _this = this;

    },
    initComponent: function() {
        Chenxin.UI.CommisionAdjust.superclass.initComponent.call(this);
    }
});

/**
*查询面板
*/
Chenxin.UI.CommisionAdjustSearch = Chenxin.extend(Chenxin.UI.SearchCommon, {
    id: 'search',
    initEvent: function() {
        var _this = this;

        //查询按钮
        $('#btn_search').click(function() {
            _this.scope.reloadGrid("",0);
        });

        var curdate = new Date();
        $('#starttime').val(curdate.getFullYear() + '-' + (curdate.getMonth() + 1) + '-1');
        if (curdate.getMonth() + 1 == 12)
            $('#eTime').val(curdate.getFullYear() + 1 + '-1-1');
        else
            $('#eTime').val(curdate.getFullYear() + '-' + (curdate.getMonth() + 2) + '-1');


        $("#txtKeyword").defText({
            deftxt: '请输入合同编号/房屋地址'
        });
    },
    createComboList: function() {
        var combl = new Chenxin.UI.StructComboList({
            tbxWidth: 65
        });

        //合同类型
        var status = new Chenxin.UI.Combo({
            containerId: '#status',
            tbxWidth: 65,
            items: comboCommon.AdjustType,
            addPleaseSelected: true
        });
        //日期类型
        var datetype = new Chenxin.UI.Combo({
            containerId: '#datetype',
            tbxWidth: 50,
            initValue:'20',
            items: [{ txt: '成交日期', val: '10' }, { txt: '调整日期', val: '20'},{ txt: '业绩归属', val: '30'}],
            addPleaseSelected: false
        });

        var structs = combl.comboList;
        structs.push(status);
        structs.push(datetype);
        return structs;
    },
    initComponent: function() {
        Chenxin.UI.CommisionAdjustSearch.superclass.initComponent.call(this);
    }
});

getcity = true; //设置需要获取城市下拉框数据

$(document).ready(function() {
    var CommisionAdjust = new Chenxin.UI.CommisionAdjust();
});